package com.jfs.qy.service.impl;

import com.jfs.qy.entity.request.SearchAlarmRtspUrlRequest;
import com.jfs.qy.entity.response.SearchAlarmRtspUrlResponse;
import com.jfs.qy.enums.NvrApiEnum;
import com.jfs.qy.service.SystemSearchAlarmRtspUrlService;
import com.jfs.qy.session.NvrSessionStorage;
import com.jfs.qy.utils.SystemCommonUtils;
import lombok.AllArgsConstructor;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

/**
 * @Description 查询通道告警视频rtsp地址接口实现类
 * @E-mail cwm3412638@163.com
 * @Author cwm
 * @Date 2022/11/5
 */
@Service
@AllArgsConstructor
public class SystemSearchAlarmRtspUrlServiceImpl implements SystemSearchAlarmRtspUrlService {
    private final SystemCommonUtils systemCommonUtils;
    private final RestTemplate restTemplate;

    @Override
    public ResponseEntity<SearchAlarmRtspUrlResponse> searchPlaybackRtspUrl(SearchAlarmRtspUrlRequest searchAlarmRtspUrlRequest) {
        String requestUrl = systemCommonUtils.getRequestUrl(NvrApiEnum.PLAYBAC_RTSPK_URL);
        final HttpEntity<?> entity = new HttpEntity<>(searchAlarmRtspUrlRequest, NvrSessionStorage.headers);
        return restTemplate.exchange(requestUrl, HttpMethod.POST, entity, SearchAlarmRtspUrlResponse.class);
    }
}
